package com.quad.innovators.salesease.common.result;


import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class PageInfo implements Cloneable{

    @Schema(description = "当前页数")
    private int currPage;

    @Schema(description = "总记录数")
    private long totalCount;

    @Schema(description = "总页数")
    private long totalPage;

    @Schema(description = "每页记录数")
    private int pageSize;

    public PageInfo() {
    }

    public PageInfo(int currPage, int pageSize, long totalCount, long totalPage) {
        this.currPage = currPage;
        this.totalCount = totalCount;
        this.totalPage = totalPage;
        this.pageSize = pageSize;
    }

    public PageInfo(int currPage, int pageSize, long totalCount) {
        this(currPage, pageSize, totalCount, (totalCount % pageSize == 0) ? (totalCount / pageSize) : (totalCount / pageSize + 1));
    }

    public PageInfo(int currPage, int pageSize) {
        this(currPage, pageSize, 0L, 0L);
    }

    @Override
    public Object clone()  {
        try {
            return super.clone();
        } catch (CloneNotSupportedException e) {
            throw new RuntimeException(e);
        }
    }
}
